﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.PolicyInjection;
using TaobaoERP.Core.Common;

namespace TaobaoERP.BusinessTaobao.Common
{
    public class AlisoftICallHandler : ICallHandler
    {
        private int _apiType = 1;
        public int apiType
        {
            get { return _apiType; }
            set { _apiType = value; }
        }
        #region ICallHandler Members
        public void Result()
        {
            switch (_apiType)
            {
                case 2:
                    if (string.IsNullOrEmpty(Utils.GetCookies("isp_username")))
                    {
                        if (string.IsNullOrEmpty(Utils.GetCookies("sessionid")))
                            Utils.SetCookies("sessionid", System.Web.HttpContext.Current.Session.SessionID);
                        System.Web.HttpContext.Current.Response.Redirect(new TaobaoERP.BusinessTaobao.TaobaoAPI.TaobaoAPI(Utils.GetCookies("sessionid")).login());

                    }
                    break;
                case 3:
                    break;
            }
        }
        public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext)
        {
            //if (input.Inputs.Count == 0)
            //{
            if (_apiType == 2)
            {
                Result();
            }
            return getNext()(input, getNext);

            //}
        }
        private int _order;
        public int Order
        {
            get
            {
                return _order;
            }
            set
            {
                _order = value;
            }
        }

        #endregion
    }
}
